package sg.edu.nus.iss.phoenix.users.delegate;

import java.util.List;

import sg.edu.nus.iss.phoenix.authenticate.entity.Role;
import sg.edu.nus.iss.phoenix.authenticate.entity.User;
import sg.edu.nus.iss.phoenix.users.service.MaintainUsersService;

/**
 * Maintain User Delegate. This class contains all delegate method for maintain user
 * 
 * @author Puwanendran Nishanthan
 */
public class MaintainUsersDelegate {

	private MaintainUsersService maintainUsersService;
	
	public MaintainUsersDelegate()
	{
		super();
		maintainUsersService = new MaintainUsersService();
	}
	
	public User resetPassword(User user)
	{
		return maintainUsersService.resetPassword(user);
	}
	public User findUser(User user){
		return maintainUsersService.findUser(user);
	}
	public void createUser(User user){
		maintainUsersService.createUser(user);
	}
	
	public void updateUser(User user){
		maintainUsersService.updateUser(user);
	}
	
	public void deleteUser(User user){
		
		try {
			maintainUsersService.deleteUser(user);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public Role findRole(long roleId){
		return maintainUsersService.findRole(roleId);
	}
	public void deleteUserRoles(long userID){
		maintainUsersService.deleteUserRoles(userID);
	}
	public List<Role> searchUserRoles(long roleId){
		return maintainUsersService.searchUserRoles(roleId);
	}
	public  void grantAccess(User uservalueObject, Role rolevalueObject, User currentUser) 
	{
		 maintainUsersService.grantAccess(uservalueObject, rolevalueObject, currentUser);
	}
}


